import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
  {
    path: '/index',
    name: 'index',
    component: () => import('../views/Index.vue'),
    children: [
      {
        path: 'index/home',
        name: 'home',
        component: () => import('../views/Index/Home.vue'),
      },
      {
        path: 'index/home1',
        name: 'home',
        component: () => import('../views/Index/Home1.vue'),
      },
      {
        path: 'index/home2',
        name: 'home',
        component: () => import('../views/Index/Home2.vue'),
      },
      {
        path: 'index/home3',
        name: 'home',
        component: () => import('../views/Index/Home3.vue'),
      },
      // 二级路由重定向
      {
        path: '/index',
        redirect: '/index/home'
      },
      //二级404
      {
        path: '*',
        component: () => import('../views/Index/NotFound2.vue'),
      }
    ]
  },
  {
    path: '/detail',
    name: 'detail',
    component: () => import('../views/Detail.vue'),
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/Login.vue'),
  },
  {
    path: '/order',
    name: 'order',
    component: () => import('../views/Order.vue'),
  },
  //一级路由定向
  {
    path: '/',
    redirect: '/index'
  },
  //404路由
  {
    path: '*',
    component: () => import('../views/NotFound.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
